package com.enbatis.mybatisplugs.base;

import com.enbatis.mybatisplugs.commons.sql.Wrapper;
import com.enbatis.mybatisplugs.commons.utils.BaseSqlProvider;
import org.apache.ibatis.annotations.*;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

public interface BaseMapper<T> {

        @InsertProvider(type= BaseSqlProvider.class,method = "addEntity")
        int addEntity( T entity);


        @InsertProvider(type= BaseSqlProvider.class,method = "saveBatch")
        int saveBatch(@Param("list")Collection<T> list,@Param("clazz")Class clazz);


        @SelectProvider(type= BaseSqlProvider.class,method = "getById")
        T getById(String tableName,Serializable id);

        //修改一条数据
        @UpdateProvider(type=BaseSqlProvider.class,method = "updateById")
        int updateById(@Param("tableName")String tableName,@Param("bean") T bean);

        @SelectProvider(type= BaseSqlProvider.class,method = "list")
        List<T> list(Wrapper<T> wrapper);


        @SelectProvider(type= BaseSqlProvider.class,method = "list")
        List<T> page(Wrapper<T> wrapper);


        @UpdateProvider(type=BaseSqlProvider.class,method = "update")
        int update(@Param("bean")T bean,@Param("wrapper")Wrapper<T> wrapper);


        @SelectProvider(type=BaseSqlProvider.class,method = "selectCount")
        int selectCount(Wrapper<T> wrapper);


        @DeleteProvider(type= BaseSqlProvider.class,method = "deleteById")
        int deleteById(@Param("tableName")String tableName,@Param("id")Serializable id);

}
